//
//  Meeting_DetailBaseInfoCell.m
//  HuaRun2
//
//  Created by admin on 17/9/4.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "Meeting_DetailBaseInfoCell.h"
#import "ImageValueLabelStyle2.h"
#import "ImageLabView.h"
#import "KeyValueLabel.h"
#import "ImageMutLineLabelView.h"
#import "Meeting_DetailModel.h"

@interface Meeting_DetailBaseInfoCell ()

//时间、时区
@property (nonatomic, strong) ImageValueLabelStyle2 * timeLable;
//地区
@property (nonatomic, strong) ImageLabView * locationLabel;
//会议类型
@property (nonatomic, strong) KeyValueLabel * meetingTypeValueLabel;
//所属大会
@property (nonatomic, strong) KeyValueLabel * ownValueLabel;
//note
@property (nonatomic, strong) ImageMutLineLabelView * noteView;

@end


@implementation Meeting_DetailBaseInfoCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

#pragma mark - life cycle
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    
    [super viewInit];
    self.contentView.backgroundColor = RGBA(249, 249, 249, 1);
    [self.contentView addSubview:self.timeLable];
    [self.contentView addSubview:self.locationLabel];
    
    [self.contentView addSubview:self.meetingTypeValueLabel];
    [self.contentView addSubview:self.ownValueLabel];
    
    [self.contentView addSubview:self.noteView];

}

- (void)layoutInit {
    
    //    [super layoutInit];
    
    weakself(ws);
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.top.mas_equalTo(ws.contentView).offset(0);
        make.bottom.mas_equalTo(ws.contentView).offset(-0);
    }];
    
    [self.timeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.backView).offset(85);
        make.right.mas_equalTo(ws.backView).offset(-kMargin10);
        make.top.mas_equalTo(ws.backView).offset(kMargin10);
    }];
    
    [self.locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(ws.timeLable);
        make.top.mas_equalTo(ws.timeLable.mas_bottom).offset(0);
    }];
    
    [self.meetingTypeValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(ws.timeLable);
        make.left.mas_equalTo(ws.backView).offset(kMargin10 );
        make.top.mas_equalTo(ws.locationLabel.mas_bottom).offset(0);
    }];

    [self.ownValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(ws.meetingTypeValueLabel);
        make.top.mas_equalTo(ws.meetingTypeValueLabel.mas_bottom).offset(0);
    }];
    [self.noteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(ws.timeLable);
        make.top.mas_equalTo(ws.ownValueLabel.mas_bottom).offset(0);
    }];
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(ws);
        make.bottom.mas_equalTo(ws.noteView).offset(0);
    }];

}

#pragma mark getter setter

- (void)setDetailModel:(Meeting_DetailModel *)detailModel {
    _detailModel = detailModel;
    _timeLable.valueLab1.text =
    [NSString showSpaceStringWithStr:detailModel.timezone];
    
    _timeLable.valueLab2.text =
    [NSString stringWithFormat:@"%@-%@",
     [NSString showSpaceStringWithStr:detailModel.startTime],
     [NSString showSpaceStringWithStr:detailModel.endTime]
     ];
    _locationLabel.nameLab.text = [NSString showSpaceStringWithStr:detailModel.location];
    
    _meetingTypeValueLabel.valueLab.text = [NSString showSpaceStringWithStr:detailModel.categories];
    _noteView.timeLab.text =[NSString showSpaceStringWithStr:detailModel.descriptionStr];
}

- (ImageLabView *)locationLabel {
    if (!_locationLabel) {
        self.locationLabel = [ImageLabView new];
//        _locationLabel.backgroundColor = kRandomColor;
//        _locationLabel.nameLab.text = kTestStr;
        _locationLabel.iconView.image = [UIImage imageNamed:@"地址_1"];
    }
    return _locationLabel;
}
- (ImageValueLabelStyle2 *)timeLable {
    if (!_timeLable) {
        self.timeLable = [ImageValueLabelStyle2 new];
        _timeLable.valueLab1.text = @"1";
        _timeLable.valueLab2.text = @"33eee";
        _timeLable.keyImageView.image = [UIImage imageNamed:@"时间_1"];
    }
    return _timeLable;
}

- (KeyValueLabel *)meetingTypeValueLabel {
    if (!_meetingTypeValueLabel) {
        self.meetingTypeValueLabel = [[KeyValueLabel alloc] init];
        _meetingTypeValueLabel.valueLab.text = @" ";
        _meetingTypeValueLabel.keyLab.text = @"会议类型";
    }
    return _meetingTypeValueLabel;
}

- (KeyValueLabel *)ownValueLabel {
    if (!_ownValueLabel) {
        self.ownValueLabel = [[KeyValueLabel alloc] init];
        _ownValueLabel.valueLab.text = @" ";
        _ownValueLabel.keyLab.text = @"所属大会";
    }
    return _ownValueLabel;
}
- (ImageMutLineLabelView *)noteView {
    if (!_noteView) {
        self.noteView = [ImageMutLineLabelView new];
        [_noteView.timeBtn setBackgroundImage:[UIImage imageNamed:@"备注000001"]
                                     forState:(UIControlStateNormal)];
    }
    return _noteView;
}

@end
